create or replace package body pk_http is
 
  function request(a_adress varchar2,aa_headers THeaders DEFAULT g_dummy_headers, a_msg varchar2 DEFAULT NULL) 
  return varchar2
  is
         l_http_request   UTL_HTTP.req;
         l_http_response  UTL_HTTP.resp;
         l_text           VARCHAR2(32767);
  begin
         -- Make a HTTP request and get the response.
        l_http_request  := UTL_HTTP.begin_request(a_adress);
        -- Put some headers
        if aa_headers.count > 0 then
          declare
               l_ind varchar2(100) := aa_headers.first();
          begin
               while l_ind IS NOT NULL LOOP
                     UTL_HTTP.set_header(l_http_request, l_ind, aa_headers(l_ind));
                     l_ind := aa_headers.NEXT(l_ind);
                 end loop;
            end;
        end if;
        -- write some measeage
        if a_msg is not null then
           utl_http.write_text(l_http_request, a_msg);
          end if;
          
        l_http_response := UTL_HTTP.get_response(l_http_request);

        -- Loop through the response.
        UTL_HTTP.read_text(l_http_response, l_text, 32766);
        UTL_HTTP.end_response(l_http_response);
        RETURN l_text;
      EXCEPTION
        WHEN OTHERS THEN
          UTL_HTTP.end_response(l_http_response);
          RAISE;
  end;
begin
  -- Initialization
  UTL_HTTP.set_wallet('file:'||'G:\arbitrage\crts', 'Fuckoff23');
end pk_http;
/
